import {
	BaseUrl,
	formatDishesScore
} from "./config"

/**
 * 查询今日菜单
 */
export function getDailyMenuDishes(date) {
	return uni.request({
		method: "POST",
		url: BaseUrl + '/dailyMenu/get',
		data: {
			date
		}
	}).then(res => {
		// console.log("查询今日菜单", res.data.data);
		const id = res.data.data.id
		const dishes = formatDishesScore(res.data.data.dishes)
		const menuTypeId = res.data.data.menuTypeId
		return {
			id,
			dishes,
			menuTypeId
		}
	})
}

/**
 * 创建今日菜单
 */
export function createDailyMenu({
	date,
	menuTypeId,
	dishIds
}) {
	return uni.request({
		method: "POST",
		url: BaseUrl + '/dailyMenu/creat',
		data: {
			date,
			menuTypeId,
			dishIds
		}
	}).then(res => res.data)
}


/**
 * 修改今日菜单
 */
export function updateDailyMenuById({
	id,
	date,
	menuTypeId,
	dishIds

}) {
	return uni.request({
		method: "POST",
		url: BaseUrl + '/dailyMenu/update',
		data: {
			id,
			date,
			menuTypeId,
			dishIds
		}
	}).then(res => res.data)
}